<template>
  <!-- 新歌推荐模块 -->
  <div class="newsong">
    <div class="title">新歌推荐</div>
    <div class="more"><a href="/songmore">更多</a></div>
    <div class="newcontent">
      <div
        class="item"
        v-for="item of newsong"
        :key="item.id"
        @click="handleDetail(item.id)"
      >
        <div class="img">
          <a href="#"><img :src="item.coverImgUrl" alt="" /></a>
        </div>
        <p>{{ item.name }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      newsong: [],
    };
  },
  mounted() {
    this.$http.get("/top/playlist").then((res) => {
      this.newsong = res.data.playlists.slice(0, 10);
    });
  },
  methods: {
    handleDetail(val) {
      this.$router.push(`/songdetail?id=${val}`);
    },
  },
};
</script>

<style scoped>
.newsong {
  width: 1200px;
  margin: 0 auto;
}
.title {
  width: 220px;
  text-align: center;
  margin: 0 auto;
  padding: 10px 0;
  border-radius: 18px;
  background-color: #abc4ff;
}
.more {
  text-align: right;
  margin-right: 30px;
}
.item {
  margin-left: 40px;
  margin-bottom: 60px;
  width: 200px;
  height: 220px;
}
.newcontent {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
}
.img {
  width: 200px;
  height: 200px;
  border-radius: 20px;
  overflow: hidden;
}
.img img {
  width: 200px;
  height: 200px;
  border-radius: 20px;
  transition: all 1s;
}
.item img:hover {
  transform: scale(1.2);
}
.item p {
  margin-top: 10px;
  text-align: center;
}
</style>